using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace ConsoleApplication2.Models.Mapping
{
    public class SO_POMap : EntityTypeConfiguration<SO_PO>
    {
        public SO_POMap()
        {
            // Primary Key
            this.HasKey(t => new { t.DATE, t.currency, t.sumfields, t.dimfields });

            // Properties
            this.Property(t => t.order__)
                .HasMaxLength(7);

            this.Property(t => t.VENDOR)
                .HasMaxLength(35);

            this.Property(t => t.VENDOR__)
                .HasMaxLength(6);

            this.Property(t => t.currency)
                .IsRequired()
                .HasMaxLength(5);

            this.Property(t => t.sumfields)
                .IsRequired()
                .HasMaxLength(33);

            this.Property(t => t.dimfields)
                .IsRequired()
                .HasMaxLength(21);

            // Table & Column Mappings
            this.ToTable("SO_PO");
            this.Property(t => t.order__).HasColumnName("order_#");
            this.Property(t => t.VENDOR).HasColumnName("VENDOR");
            this.Property(t => t.VENDOR__).HasColumnName("VENDOR_#");
            this.Property(t => t.DATE).HasColumnName("DATE");
            this.Property(t => t.PO_AMOUNT_Base1).HasColumnName("PO_AMOUNT_Base1");
            this.Property(t => t.PO_AMOUNT_Base2).HasColumnName("PO_AMOUNT_Base2");
            this.Property(t => t.PO_AMOUNT).HasColumnName("PO_AMOUNT");
            this.Property(t => t.currency).HasColumnName("currency");
            this.Property(t => t.sumfields).HasColumnName("sumfields");
            this.Property(t => t.dimfields).HasColumnName("dimfields");
        }
    }
}
